package com.lkm.market2_0.m_imple.steelyardserver.server.cmd_handle;

import com.lkm.frame.P;
import com.lkm.javatool.NumberHelp;
import com.lkm.market2_0.ExpandConfig;
import com.lkm.market2_0.help.UIP;
import com.lkm.market2_0.m.app_main.AppMainModule;
import com.lkm.market2_0.m.steelyardserver.SteelyardServerModule;
import com.lkm.market2_0.m_imple.steelyardserver.server.AbsReceiverDataHandle;
import com.lkm.market2_0.m_imple.steelyardserver.server.CMDEntity;
import com.lkm.market2_0.m_imple.steelyardserver.server.ICMDHandle;




public class CMDInputSetOkPasswordHandle implements ICMDHandle {

    AppMainModule mAppServerModule;
    SteelyardServerModule mSteelyardServerModule;

    public CMDInputSetOkPasswordHandle() {
        mAppServerModule = ExpandConfig.instance.getModuleManager().loadModule(AppMainModule.class);
        this.mSteelyardServerModule= ExpandConfig.instance.getModuleManager().loadModule(SteelyardServerModule.class);
    }

    @Override
    public AbsReceiverDataHandle handle(CMDEntity cmdEntity) {

        if(mAppServerModule==null)
        mAppServerModule = ExpandConfig.instance.getModuleManager().loadModule(AppMainModule.class);


        byte[] data=cmdEntity.getData();

        String okPassword="" + NumberHelp.bytesToIntDesc(new byte[]{data[0],data[1]});

        if(P.isDebug()) {
            P.p("=====CMD请求设置称为OK 密码 " + okPassword);
            if(UIP.isPrint()){
                UIP.p("CMD请求设置称为OK 密码："+okPassword,cmdEntity.getSteelyardMac());
            }
        }

        mSteelyardServerModule.tickOK_block(cmdEntity.getSteelyardMac());

        mAppServerModule.requestSetSteelyardOkForS(cmdEntity.getSteelyardMac(),okPassword);


        return null;
    }




}
